package service

import (
	"gin-demo/dao"
	"gin-demo/entity"
)

type UserService interface {
	GetUserById(id int64) (*entity.User, error)
	GetUserRoles(id int64) (*[]string, error)
}

type userServiceImpl struct {
	userDao dao.UserDao
}

func NewUserService(userDao dao.UserDao) UserService {
	return &userServiceImpl{userDao}
}

func (u *userServiceImpl) GetUserById(id int64) (*entity.User, error) {
	user, err := u.userDao.GetUserById(id)
	if err != nil {
		return nil, err
	}
	return user, nil
}

func (u *userServiceImpl) GetUserRoles(id int64) (*[]string, error) {
	roles, err := u.userDao.GetUserRoles(id)
	if err != nil {
		return nil, err
	}
	return roles, nil
}
